<?php

 /*
    注册 后端
  */

  $username = $_POST['username'];
  $password = $_POST['password'];

  $link = mysqli_connect('localhost', 'root', 'root', 'dhsc');
  $sql = "SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password'";
  $res = mysqli_query($link, $sql);
  $data = mysqli_fetch_all($res, MYSQLI_ASSOC);

  mysqli_close($link);

  if (count($data)) {
 
    $arr = [
      "message" => "登录成功",
      "code" => 1,
      "info" => $data
    ];
  } else {

    $arr = [
      "message" => "登录失败",
      "code" => 0,
    ];
  }

  echo json_encode($arr);
?>